
#ifndef MouseAndCat_Message_h
#define MouseAndCat_Message_h

#include "Types.h"

struct Message
{
public:

    static const abyte kEventNone = 0;
    static const abyte kEventMouseEnter = 1;
    static const abyte kEventMouseLeave = 2;
    static const abyte kEventMouseMove = 3;
    static const abyte kEventMouseDown = 4;
    static const abyte kEventMouseUp = 5;
    static const abyte kEventLeftMouseDoubleClick = 6;
    static const abyte kEventRightMouseDown = 7;
    static const abyte kEventRightMouseUp = 8;
    static const abyte kEventMouseWheel = 9;
    static const abyte kEventKeyUp = 10;
    static const abyte kEventKeyDown = 11;

    static const abyte kMessageSize = 10;

	static const abyte kCoordinateRelative = 1;
	static const abyte kCoordinateAbsolute = 2;
    
    // TODO: Turn this into a Union
    uint  time_stamp;
    abyte event_type;
    abyte coordinate_type;
    //  Mouse Move      Mouse Button            Mouse Wheel             Keyboard
        int16_t x;      abyte button_mask;      int16_t wheel_delta;    abyte modifier;
        int16_t y;                                                      abyte key;
    

	Message();
    ~Message();
    
    static Message& Parse(const abyte*, int*, Message&);
    
    void GetBytes(abyte*);
    
    //const char* ToString();
    
private:
    
    //static const int sz_timestamp = sizeof(uint32_t);
    //static const int sz_short = sizeof(short);
    //static const int sz_event = sizeof(abyte);
    //static const int sz_keyboard = sz_timestamp + sz_event + (sizeof(abyte) * 2);
    //static const int sz_mouse =    sz_timestamp + sz_event + (sz_short * 2);
    //static const int sz_switch =   sz_timestamp + sz_event + (sz_short * 2);
    
    void GetXY(short x, short y, abyte*);
    void AddDeviceData(abyte*);
};

#endif
